package com.cskaoyan.dbutills;

import com.cskaoyan.bean.Account;
import com.cskaoyan.dbutills.resultset.impl.MyResultSetHandler;
import com.cskaoyan.utils.DruidUtils;
import org.apache.commons.dbutils.QueryRunner;

import javax.sql.DataSource;
import java.sql.SQLException;
import java.util.List;

/**
 * 创建日期: 2022/10/11 14:45
 *
 * @author ciggar
 */
public class ResultSetHandlerDemo1 {


    public static void main(String[] args) throws SQLException {

        // 获取数据库连接池
        DataSource dataSource = DruidUtils.getDataSource();

        // 构建一个queryRunner
        QueryRunner queryRunner = new QueryRunner(dataSource);


        // update/query
        List<Account> accounts = (List<Account>) queryRunner.query("select * from account where id = ?", new MyResultSetHandler(), 1002);


        System.out.println(accounts);


    }
}
